package io.renren.constant;

import io.renren.enums.ResultCodeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

@EqualsAndHashCode(callSuper = true)
@Data
public class BizSystemException extends RuntimeException {

    private Integer code;
    private String message;

    /**
     * 通过状态码和错误消息创建异常对象
     *
     */
    public BizSystemException(Integer code, String message) {
        super(message);
        this.message = message;
        this.code = code;
    }

    public BizSystemException(String message) {
        super(message);
        this.message=message;
        this.code = -1;
    }

    /**
     * 接收枚举类型对象
     *
     */
    public BizSystemException(ResultCodeEnum resultCodeEnum) {
        super(resultCodeEnum.getMessage());
        this.code = resultCodeEnum.getCode();
    }

    @Override
    public String toString() {
        return "CustomException{" +
                "code=" + code +
                ", message=" + this.getMessage() +
                '}';
    }
}
